Skip to content

Prevent conn leak on thread interrupt#6835

Merged
dagnir merged 4 commits intomasterfrom
dongie/apache5-connection-leak-interrupt
Apr 3, 2026
Merged

Prevent conn leak on thread interrupt#6835
dagnir merged 4 commits intomasterfrom
dongie/apache5-connection-leak-interrupt

Conversation

@dagnir
Copy link
Copy Markdown
Contributor

@dagnir dagnir commented Mar 31, 2026

Motivation and Context

If a thread blocked waiting on a connection pool is interrupted, it's possible for the connection to become leaked if the pool then completes the future from its side.

This commit prevents that from happening by intercepting the interrupt and attempting to cancel the lease future. If that is unsuccessful, the connection is returned to the upper, and the thread is reinterrupted.

Adresses #6786

Modifications

Testing

  • New wiremock test

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • I have read the CONTRIBUTING document
  • Local run of mvn install succeeds
  • My code follows the code style of this project
  • My change requires a change to the Javadoc documentation
  • I have updated the Javadoc documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed
  • I have added a changelog entry. Adding a new entry must be accomplished by running the scripts/new-change script and following the instructions. Commit the new file created by the script in .changes/next-release with your changes.
  • My change is to implement 1.11 parity feature and I have updated LaunchChangelog

License

  • I confirm that this pull request can be released under the Apache 2 license

If a thread blocked waiting on a connection pool is interrupted, it's
possible for the connection to become leaked if the pool then completes
the future from its side.

This commit prevents that from happening by intercepting the interrupt
and attempting to cancel the lease future. If that is unsuccessful, the
connection is returned to the upper, and the thread is reinterrupted.

Adresses #6786
@dagnir dagnir requested a review from a team as a code owner March 31, 2026 21:41
@dagnir dagnir added the no-api-surface-area-change Indicate there is no API surface area change and thus API surface area review is not required label Mar 31, 2026
@dagnir
Copy link
Copy Markdown
Contributor Author

dagnir commented Mar 31, 2026

dagnir added the no-api-surface-area-change label

There's a change in Apache5HttpClient but only to internal methods.

@dagnir dagnir force-pushed the dongie/apache5-connection-leak-interrupt branch from 20e5f72 to 3e80bdc Compare April 3, 2026 20:51
@dagnir dagnir enabled auto-merge April 3, 2026 20:52
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 3, 2026

Quality Gate Failed Quality Gate failed

Failed conditions
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@dagnir dagnir added this pull request to the merge queue Apr 3, 2026
Merged via the queue into master with commit 720dbf0 Apr 3, 2026
38 of 41 checks passed
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 3, 2026

This pull request has been closed and the conversation has been locked. Comments on closed PRs are hard for our team to see. If you need more assistance, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 3, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

no-api-surface-area-change Indicate there is no API surface area change and thus API surface area review is not required

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants